package com.rybbaby.tss.tasks.core.task.dao.imp;

import com.rybbaby.tss.tasks.core.bean.PageBean;
import com.rybbaby.tss.tasks.core.task.dao.ITssMemberAttendClassRecordDao;
import com.rybbaby.tss.tasks.core.task.entity.TssMemberAttendClassRecord;
import com.rybbaby.tss.tasks.core.web.dao.imp.GenericDao;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description 会员报班记录表数据库操作实现
 * 
 * @author 雷春琼
 * 
 * @createDate 2017-08-24 下午2:43:28
 */
@Repository
public class TssMemberAttendClassRecordDaoImp extends GenericDao<TssMemberAttendClassRecord> implements ITssMemberAttendClassRecordDao {

    /**
     * 根据会员课时包和班级id查询已报班信息
     *
     * @param memberPackageId
     * @param classId
     * @return
     */
    @Override
    public List<Map<String, Object>> classDateList(String memberPackageId, String classId) {
        String sql="SELECT\n" +
                "\ta.classDate\n" +
                "FROM\n" +
                "\ttss_member_attend_class_record a\n" +
                "LEFT JOIN tss_member_package p ON p.id = a.memberPackageId\n" +
                "WHERE p.id =?  AND classId = ?";
        return this.findForJdbc(sql,new Object[]{memberPackageId,classId});
    }

    /**
     * 根据会员课时包id分组查询会员报班记录
     *
     * @param memberPackageId
     * @return
     */
    @Override
    public PageBean tssMemberAttendClassRecordListGroupByClass(String memberPackageId, Integer pageNo, Integer pageSize) {
        String sql="SELECT\n" +
                "\ta.classId\n" +
                "FROM\n" +
                "\ttss_member_attend_class_record a\n" +
                "LEFT JOIN tss_member_package p ON p.id = a.memberPackageId\n" +
                "WHERE a.memberPackageId ='"+memberPackageId+"'  GROUP BY  classId";
        return this.pageList(sql,pageNo,pageSize);
    }

    @Override
    public List<Map<String, Object>> memberPackageIdList(String classId) {
        String sql ="";

        return this.findForJdbc(sql,new Object[]{classId});
    }
}
